//获取当前日期的Fulldate和当前时间
export function getTodayInfo(today) {
    const y = today.getFullYear();
    const m = today.getMonth() + 1 < 10 ? '0' + (today.getMonth() + 1) : today.getMonth() + 1; // 获取当前月份的日期，不足10补0
    const d = today.getDate() < 10 ? '0' + today.getDate() : today.getDate(); // 获取当前几号，不足10补0
    const hour = today.getHours() < 10 ? '0' + today.getHours() : today.getHours();
    const minute = today.getMinutes() < 10 ? '0' + today.getMinutes() : today.getMinutes();
    const second = today.getSeconds() < 10 ? '0' + today.getSeconds() : today.getSeconds();
    var date = y + '-' + m + '-' + d;
    var time = hour + ':' + minute + ':' + second;

    return {
        'date': date,
        'time': time
    };
}

//去掉时间的秒位
export function eraseSeconds(time) {
    var minuteEnd = time.lastIndexOf(':');
    return time.substr(0, minuteEnd);
}

//去掉日期的年位
export function eraseYear(date) {
    var month_start = date.indexOf('-');
    if(month_start < 0)
        return '';
    var month = date.substr(month_start + 1, date.length - month_start);
    return month;
}
